﻿@using TextAdventures.Quest
@using WebEditor.Views.Edit
@model WebEditor.Models.Controls.MultiControl

@{
    IEditorControl ctl = Model.Control;
    object value = Model.Value;
    string caption = ctl.GetString("selfcaption");
    if (caption != null)
    {
        <text>@caption:</text>
    }
    IDictionary<string, string> types = ctl.GetDictionary("types");
    string selectedType = ControlHelpers.GetTypeName(value);
    @Html.DropDownList(ctl.Attribute + "-type", types.Select(t => new SelectListItem { Text = t.Value, Value = t.Key, Selected = (t.Key == selectedType) }), new { @class = "multi-dropdown", data_key = ctl.Attribute })
    <br />
    string controlType = ControlHelpers.GetEditorNameForType(selectedType, ctl.GetDictionary("editors"));
    string ctlCaption = null;
    if (controlType == "checkbox")
    {
        ctlCaption = ctl.GetString("checkbox");
    }

    var model = new WebEditor.Models.Controls.EditorControl
    {
        GameId = Model.GameId,
        Key = Model.Key,
        Controller = Model.Controller,
        EditorData = Model.EditorData,
        Control = ctl,
        IsFirst = false,
        ControlType = controlType,
        Caption = ctlCaption
    };
    Html.RenderPartial("Controls/EditorControl", model);
}